import { createApp } from 'vue';
import Dialog from '@/components/common/Dialog.vue'
let dialog=null
const showDialog=(opt) =>{
  dialog=createApp(Dialog,{
    title:opt.title,
    content:opt.content,
    showCancelBtn:opt.showCancelBtn,
    comfirm(){
      hideDialog()
      opt.comfirm?.()
    },
    cancel(){
      hideDialog()
      opt.cancel?.()
    }
  })
  const fragment:any=document.createDocumentFragment()
  dialog.mount(fragment)
  document.body.appendChild(fragment)
}
const hideDialog=() =>{
  if(!dialog) return
  dialog.unmount()
}
export {
  showDialog,hideDialog
}